#include <STC89C5xRC.H>
#include "Delay.h"

unsigned char NiXie_Buf[]={0,10,10,10,10,10,10,10,10,10};

unsigned char NiXieTable[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x40};

void NiXie_SetBuf(unsigned char Location,Number)
{
	NiXie_Buf[Location]=Number;
}

void NiXie_Scan(unsigned char Location,Number)
{
	P0=0x00;
	switch(Location)
	{
		case 1:P24=1;P23=1;P22=1;break;
		case 2:P24=1;P23=1;P22=0;break;
		case 3:P24=1;P23=0;P22=1;break;
		case 4:P24=1;P23=0;P22=0;break;
		case 5:P24=0;P23=1;P22=1;break;
		case 6:P24=0;P23=1;P22=0;break;
		case 7:P24=0;P23=0;P22=1;break;
		case 8:P24=0;P23=0;P22=0;break;
	}
	P0=NiXieTable[Number];
}

void NiXie_Loop()
{
	static unsigned char i=1;
	NiXie_Scan(i,NiXie_Buf[i]);
	i++;
	while(i==9){i=1;}
}